package test1;

public class Test2 {
    public static void main(String[] args) {
        int[] array={1,2,3};
        try{
            array=null;
            System.out.println(array[2]);
            System.out.println("hahaha");
        }catch (ArrayIndexOutOfBoundsException | NullPointerException e){
            e.printStackTrace();
            System.out.println("我捕捉到了一个数组越界异常/空指针异常");
        }
        System.out.println("哈喽");


    }

    public static void main1(String[] args) {
        int[] array={1,2,3};
        try{
            array=null;
            System.out.println(array[2]);
            System.out.println("hahaha");
        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            System.out.println("我捕捉到了一个数组越界异常");
        }catch(NullPointerException e){
            e.printStackTrace();
            System.out.println("空指针异常");
        }
        System.out.println("哈喽");
    }
}
